package hl.games.tankwar.factorys;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import hl.games.tankwar.core.ASortKeys;
import hl.games.tankwar.entity.SortKey;
import hl.games.tankwar.ui.R;

public class SortKeyFactory {
		
		public static ASortKeys cerateFireKeys(Context context,int locationX,int locationY) {
			Bitmap upKeyBitmap=BitmapFactory.decodeResource(context.getResources(), R.drawable.fire_key);
			ASortKeys key=new SortKey(upKeyBitmap,66,66,true);
			key.setPosition(locationX, locationY);
			return key;
		}
		
		public static ASortKeys[] creatArrowKeys(Context context,int leftKeyX,int leftKeyY) {
			ASortKeys[] sortKeys=null;
			try {
				Bitmap leftKeyBitmap=BitmapFactory.decodeResource(context.getResources(), R.drawable.arrow_key_left);
				Bitmap centerKeyBitmap=BitmapFactory.decodeResource(context.getResources(), R.drawable.arrow_key_center);
				Bitmap downKeyBitmap=BitmapFactory.decodeResource(context.getResources(), R.drawable.arrow_key_down);
				Bitmap rightKeyBitmap=BitmapFactory.decodeResource(context.getResources(), R.drawable.arrow_key_right);
				Bitmap upKeyBitmap=BitmapFactory.decodeResource(context.getResources(), R.drawable.arrow_key_up);
				
				ASortKeys leftkey=new SortKey(leftKeyBitmap, 34,50,false);
				leftkey.setPosition(leftKeyX, leftKeyY);
				

				ASortKeys centerkey=new SortKey(centerKeyBitmap, 44,52,false);
				centerkey.setPosition(leftKeyX+leftKeyBitmap.getWidth(),leftKeyY);
				

				ASortKeys upkey=new SortKey(upKeyBitmap, 42,34,false);
				upkey.setPosition(leftKeyX+leftKeyBitmap.getWidth(), leftKeyY-upKeyBitmap.getHeight());
				
				ASortKeys downkey=new SortKey(downKeyBitmap, 42,32,false);
				downkey.setPosition(leftKeyX+leftKeyBitmap.getWidth(),leftKeyY+leftKeyBitmap.getHeight());
				
				ASortKeys rightkey=new SortKey(rightKeyBitmap, 36,50,false);
				rightkey.setPosition(leftKeyX+leftKeyBitmap.getWidth()+centerKeyBitmap.getWidth(),leftKeyY);
				
				sortKeys=new ASortKeys[]{leftkey,upkey,downkey,rightkey,centerkey};
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return sortKeys;
		}
}
